<template>
  <div class="default-bar">
    <div class="center-view">
      <div class="jd-card">
        <img src="../../../assets/imgs/user/jd_logo.png" alt="京东会员logo">
        <div class="jd-name"> admin</div>
        <div class="items">
          <span>京东会员</span>
          <span>开启小白守约特权</span>
        </div>
        <div class="mb">
          <div class="text">
            <em>开通PLUS会员尊享</em>
            <span>自营无门槛不限次免邮</span>
          </div>
          <a class="button" href="//plus.jd.com/index?flow_system=myhome&amp;flow_entrance=myhome1&amp;flow_channel=pc"
            target="_blank" rel="noopener noreferrer" clstag="homepage|keycount|infowallet_1530067239746|7">立即开通</a>
        </div>
      </div>
      <!-- 钱包部分 -->
      <div class="botton-view">
        <div class="top-header">
          <p>我的钱包</p>
          <!-- 根据isVisible状态显示不同的图标 -->
          <i :class="isVisible ? 'iconfont icon-yanjing' : 'iconfont icon-biyanjing'" @click="toggleVisibility"></i>
        </div>
        <div class="data-container">
          <div class="data-panel" v-for="(item, index) in items" :key="index">
            <div class="panel-content">
              <!-- 根据isVisible状态显示真实数据或掩码 -->
              <span class="d-number">{{ isVisible ? item.number : (item.mask || '***') }}</span>
              <span class="d-text">{{ item.text }}</span>
            </div>
            <span class="d-action" v-if="item.action">{{ item.action }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="bottom-view">
      <MyOrders />
      <MyServers />
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import MyOrders from './components/MyOrders.vue'
import MyServers from './components/MyServers.vue'
// 为每个数据项添加mask属性，定义隐藏时显示的内容
const items = [
  { number: '2', text: '优惠券', action: '', mask: '**' },
  { number: '11', text: '京豆', action: '赚京豆 | 花京豆', mask: '**' },
  { number: '0.00', text: '余额', action: '', mask: '*.**' },
  { number: '——', text: '暂未开通白条', action: '开通', mask: '——' },
  { number: '0.00', text: '小金库昨日收益', action: '', mask: '*.**' }
];

// 控制数据可见性的状态变量
const isVisible = ref(true);

// 切换数据可见性的方法
const toggleVisibility = () => {
  isVisible.value = !isVisible.value;
};
</script>

<style scoped lang="scss">
.default-bar {
  height: auto;

  .center-view {
    padding: 20px 0;
    height: 243px;
    display: grid;
    grid-template-columns: 250px auto;

    .jd-card {
      background-color: rgb(226, 35, 26);
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 15px 0;

      img {
        border: 2px solid white;
        width: 73px;
        height: 73px;
        border-radius: 9999px;
      }

      .jd-name {
        color: white;
        font-size: 18px;
        margin: 10px 0;
      }

      .items {
        display: flex;
        gap: 8px;
        margin-bottom: 10px;

        span {
          border-radius: 10px;
          background-color: #eb645e;
          padding: 2px 10px;
          color: #fff;
          font-size: 14px;
        }
      }

      .mb {
        padding: 10px 20px;
        bottom: 0;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
        background: linear-gradient(90deg, #6a5645, #3a2d23);
        position: relative;

        .text {
          text-align: left;
          color: #f6d9c2;

          em {
            font-size: 13px;
            font-weight: 700;
          }

          span {
            display: block;
            font-size: 12px;
          }
        }

        .button {
          position: absolute;
          top: 10px;
          right: 20px;
          padding: 0 10px;
          height: 26px;
          line-height: 26px;
          border-radius: 14px;
          background-color: #f6d9c2;
          color: #232331;
          font-weight: 700;
          text-align: center;
          text-decoration: none;
          font-size: 14px;
        }
      }
    }

    .botton-view {
      background-color: #fff;
      margin-top: 15px;
      border-radius: 8px;
      overflow: hidden;

      .top-header {
        padding: 12px 20px;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        align-items: center;

        p {
          font-size: 16px;
          color: #333;
          margin: 0;
        }

        .iconfont {
          color: #999;
          font-size: 18px;
          cursor: pointer;
          transition: color 0.3s;

          &:hover {
            color: #333;
          }
        }
      }

      .data-container {
        display: flex;
        justify-content: space-around;
        padding: 20px 10px;
        flex-wrap: wrap;

        .data-panel {
          flex: 1;
          min-width: 80px;
          display: flex;
          flex-direction: column;
          align-items: center;
          position: relative;

          .panel-content {
            text-align: center;
            width: 100%;
          }

          .d-number {
            display: block;
            font-size: 20px;
            color: #333;
            font-weight: 700;
            margin-bottom: 5px;
          }

          .d-text {
            display: block;
            font-size: 14px;
            color: #666;
          }

          .d-action {
            margin-top: 10px;
            font-size: 12px;
            color: #165DFF;
            cursor: pointer;
          }

          &:first-child {
            .panel-content {
              text-align: left;
              padding-left: 15px;
            }
          }
        }
      }
    }
  }

  .bottom-view {
    margin-top: 20px;
    display: grid;
    grid-template-columns: 750px auto;
    grid-template-rows: 450px;
    gap: 20px;
  }
}
</style>
